#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
inline void chmax(int &x,int y){if(y>x)x=y;}
const int N=1e6;
int main(){
  freopen("stone.in","r",stdin);
  freopen("stone.out","w",stdout);
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int q; cin>>q;
  if(q<=12000){
    map<pii,int> mp;
    multiset<int> S;
    vector<multiset<int> > sl(N),sr(N);
    while(q--){
      char op; int l,r; cin>>op>>l>>r,l--,r-=2;
      if(op=='A'){
        sl[l].emplace(r),sr[r].emplace(l);
        mp[make_pair(l,r)]++,S.emplace(r);
      }
      else{
        sl[l].erase(sl[l].find(r)),sr[r].erase(sr[r].find(l));
        S.erase(S.find(r));
        if(!--mp[make_pair(l,r)])mp.erase(make_pair(l,r));
      }
      int L=prev(mp.end())->first.first,R=*S.begin();
      if(L<=R){
        int l=min(L,*prev(sr[R].end())),r=max(R,*sl[L].begin());
        cout<<r-l+1<<'\n';
      }
      else{
        auto it=S.begin();
        int L=-N,R=N;
        for(auto e:mp){
          while(it!=S.end()&&*it<e.first.first)
            chmax(L,*prev(sr[*it++].end()));
          R=min(R,e.first.second-L+1);
        }
        cout<<R<<'\n';
      }
    }
    return 0;
  }
  set<pii> S;
  multiset<int> R;
  while(q--){
    char op; int l,r; cin>>op>>l>>r,l--,r-=2;
    if(op=='A'){
      auto it=S.emplace(l,r).first;
      if(it!=S.begin())R.emplace(r-prev(it)->first+1);
      if(next(it)!=S.end())R.emplace(next(it)->second-l+1);
      if(it!=S.begin()&&next(it)!=S.end())R.erase(R.find(next(it)->second-prev(it)->first+1));
    }
    else{
      auto it=S.find(make_pair(l,r));
      if(it!=S.begin())R.erase(R.find(r-prev(it)->first+1));
      if(next(it)!=S.end())R.erase(R.find(next(it)->second-l+1));
      if(it!=S.begin()&&next(it)!=S.end())R.emplace(next(it)->second-prev(it)->first+1);
      S.erase(make_pair(l,r));
    }
    cout<<(R.empty()?S.begin()->second-S.begin()->first+1:*R.begin())<<'\n';
  }
  return 0;
}